From 15e98c91124866a342b3eb491a55c6054c8ddecb Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Mon, 20 May 2024 23:53:10 -0700
Subject: feat(badges): individual badges shadow hiding

---
 src/routes/user/[user]/badges/+page.svelte | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

(limited to 'src/routes/user/[user]/badges/+page.svelte')

diff --git a/src/routes/user/[user]/badges/+page.svelte b/src/routes/user/[user]/badges/+page.svelte
index d81cea28..6d34a204 100644
--- a/src/routes/user/[user]/badges/+page.svelte
+++ b/src/routes/user/[user]/badges/+page.svelte
@@ -451,6 +451,17 @@
 	const castAsStringArray = (array: any[]) => array as string[];
 
 	const castBadgesToIndexedBadges = (array: any[]) => array as IndexedBadge[];
+
+	const shadowHideBadge = () => {
+		if (!selectedBadge && !authorised) return;
+
+		badgesPromise = fetch(
+			`/api/badges?shadowHideBadge=${selectedBadge?.id}&status=${selectedBadge?.shadow_hidden}`,
+			{
+				method: 'PUT'
+			}
+		);
+	};
 </script>
 
 <HeadTitle route={`${data.username}'s Badge Wall`} path={`/user/${data.username}`} />
@@ -826,6 +837,19 @@
 									Next
 								</button>
 							{/if}
+
+							{#if authorised}
+								<br />
+								<br />
+
+								<button on:click={shadowHideBadge}>
+									{#if selectedBadge && selectedBadge.shadow_hidden}
+										Un-shadow
+									{:else}
+										Shadow
+									{/if} Hide Badge ({selectedBadge ? selectedBadge.id : 0})
+								</button>
+							{/if}
 						</Popup>
 					{/if}
 				{:catch}
-- 
cgit v1.2.3

